package cn.hnu.jpa.jpaExample.OneToMany.SingleWay;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.OneToMany;

@Entity
public class TableCustomer implements Serializable{

	/**
	 * 表关联 用第三方表表示两者之间的关系 一对多
	 */
	private static final long serialVersionUID = 1L;

	private Integer id;
	
	private String name;
	
	private List<ModelAddr> addrs = new ArrayList<ModelAddr>();

	@Id @GeneratedValue(strategy = GenerationType.AUTO)
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	@OneToMany(cascade = {CascadeType.ALL})
	@JoinTable(name = "table_cus_addr",
			joinColumns = {@JoinColumn(name = "cus_id",referencedColumnName = "id")},
			inverseJoinColumns = {@JoinColumn(name="addr_id",referencedColumnName = "id")}
	)
	public List<ModelAddr> getAddrs() {
		return addrs;
	}

	public void setAddrs(List<ModelAddr> addrs) {
		this.addrs = addrs;
	}
	
	
}
